package learning.spring.helloworld.renderers;

import learning.spring.helloworld.providers.MessageProvider;

/**
 * Created with IntelliJ IDEA.
 * User: bibro
 * Date: 18.02.14
 * Time: 20:05
 * To change this template use File | Settings | File Templates.
 */
public class StandardOutMessageRenderer implements MessageRenderer {

    private MessageProvider messageProvider;

    @Override
    public void render() {
        if (messageProvider == null)
            throw new RuntimeException("You must set MessageProvider");
        System.out.println(messageProvider.getMessage());
    }

    @Override
    public void setMessageProvider(MessageProvider messageProvider) {
        this.messageProvider = messageProvider;
    }

    @Override
    public MessageProvider getMessageProvider() {
        return messageProvider;
    }
}
